package com.ht.service.impl;

import cn.hutool.core.bean.BeanUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.ht.domain.bo.TbCitiesBO;
import com.ht.domain.po.TbCities;
import com.ht.mapper.TbCitiesMapper;
import com.ht.service.TbCitiesService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

@Service
public class TbCitiesServiceImpl implements TbCitiesService {
    @Autowired
    private TbCitiesMapper tbCitiesMapper;

    @Override
    public List<TbCitiesBO> queryByCity(Long provinceId) {
        QueryWrapper<TbCities> q = new QueryWrapper<>();
        q.eq("province_id",provinceId);
        List<TbCities> list = tbCitiesMapper.selectList(q);
        List<TbCitiesBO> listt = new ArrayList<>();
        list.forEach(obj->{
            TbCitiesBO bo = new TbCitiesBO();
            BeanUtil.copyProperties(obj,bo);
            listt.add(bo);
        });
        return listt;
    }
}
